package com.niu1078;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Toast;

import com.niu1078.joe.delegates.JoeDelegate;
import com.niu1078.joe.net.RestClient;
import com.niu1078.joe.net.callback.IError;
import com.niu1078.joe.net.callback.IFailure;
import com.niu1078.joe.net.callback.ISuccess;
import com.niu1078.joe.utils.log.JoeLog;

/**
 * author :ywq .
 * time: 2017/12/19:13:34.
 * desc :测试文件
 * action:
 */

public class ExampleDelegate extends JoeDelegate {
    @Override
    public Object setLayout() {
        return R.layout.activity_main;
    }

    @Override
    public void onBindView(@Nullable Bundle savedInstanceState, View rootview) {
        testRestClient();
    }

    private void testRestClient() {

        RestClient.builder()
                .url("http://127.0.0.1/index")
                .loader(getContext())
                .success(new ISuccess() {
                    @Override
                    public void onSuccess(String response) {
                        JoeLog.json("json",response);
                        Toast.makeText(getContext(), response, Toast.LENGTH_SHORT).show();
                    }
                })
                .error(new IError() {
                    @Override
                    public void onError(int code, String msg) {

                    }
                })
                .failure(new IFailure() {
                    @Override
                    public void onFailure() {

                    }
                })
                .build().get();


    }
}
